package com.lant.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lant.enums.ResponseStatusEnum;
import com.lant.pojo.LantResult;
import com.lant.service.RedisService;

@RestController
public class HelloController {

	@Autowired
	private RedisService redisService;

	@GetMapping("/get")
	public String get(String key) {
		LantResult lantResult = redisService.get(key);
		if (lantResult.getStatus().equals(ResponseStatusEnum.OK.getValue())) {
			return lantResult.getData().toString();
		}
		return lantResult.getMsg();
	}

	@GetMapping("/set")
	public String set(String key, String value, int second) {
		LantResult lantResult = redisService.set(key, value, second);
		return lantResult.getMsg();
	}

	@GetMapping("/del")
	public String del(String key) {
		LantResult lantResult = redisService.del(key);
		return lantResult.getMsg();
	}
}
